// 初始化按钮状态

export default function updateButtonStatus(orgVal, agreementType, isEdit) {
    let cardFlag = this.state.pageFlag === 'card';
    if (cardFlag) { // 默认展开卡片界面
        this.props.form.openArea(agreementType + 'CardBefore');
        this.props.form.openArea(agreementType + 'CardAfter');
    }
    const optionData = this.props.editTable.getAllRows(agreementType, true);
    const flag = (optionData && optionData.length > 0);// 是否有数据
    //设置可见
    this.props.button.setButtonVisible({
        add: !!(orgVal.refpk && !isEdit),
        edit: !!(orgVal.refpk && !isEdit && cardFlag),
        delete: !!(orgVal.refpk && !isEdit),
        text: !!(orgVal.refpk && !isEdit && cardFlag),
        refresh: !!(orgVal.refpk && !isEdit),
        effect: !!(orgVal.refpk && !isEdit),
        file: !!(orgVal.refpk && !isEdit && cardFlag),
        save: !!(orgVal.refpk && isEdit),
        cancel: !!(orgVal.refpk && isEdit),
        query: !!(orgVal.refpk && !isEdit && !cardFlag)
    });
    //设置可编辑
    this.props.button.setButtonDisabled({
        edit: !flag && !cardFlag,
        delete: !flag && !cardFlag,
        effect: !flag && !cardFlag
    });

}
